

#ifndef UD_DBPL_H
#define UD_DBPL_H 1

#include "zdbmain.h"
#include "zdbcurve.h"

#include "zgelnsg2d.h"
#include "zgelnsg3d.h"
#include "zgearc2d.h"
#include "zgearc3d.h"
#include "zgept2dar.h"
#include "zdbboiler.h"

#pragma pack(push, 8)

class UcDb2dPolyline;

class UcDbPolyline : public UcDbCurve
{

public:
                      UcDbPolyline();
                      UcDbPolyline(unsigned int num_verts);
    virtual          ~UcDbPolyline();

    UCDB_DECLARE_MEMBERS(UcDbPolyline);

    virtual Ucad::ErrorStatus convertFrom(UcDbEntity*& pPline, 
                                  ZSoft::Boolean transferId = ZSoft::kTrue);
    Ucad::ErrorStatus convertTo(UcDb2dPolyline*&  pPline,
                                ZSoft::Boolean transferId = ZSoft::kTrue) const;

    Ucad::ErrorStatus getPointAt(unsigned int, UcGePoint3d& pt) const;

    enum SegType {
        kLine,
        kArc,
        kCoincident,
        kPoint,
        kEmpty
    };

    SegType           segType           (unsigned int index) const;

    Ucad::ErrorStatus getLineSegAt      (unsigned int index,
                                         UcGeLineSeg2d& ln) const;
    Ucad::ErrorStatus getLineSegAt      (unsigned int index,
                                         UcGeLineSeg3d& ln) const;
    Ucad::ErrorStatus getArcSegAt       (unsigned int index,
                                         UcGeCircArc2d& arc) const;
    Ucad::ErrorStatus getArcSegAt       (unsigned int index,
                                         UcGeCircArc3d& arc) const;
    virtual ZSoft::Boolean onSegAt      (unsigned int index, const UcGePoint2d& pt2d,
                                         double& param) const;

    virtual void              setClosed       (ZSoft::Boolean);
    void		              setPlinegen     (ZSoft::Boolean);
    virtual void			  setElevation    (double);
	virtual	Ucad::ErrorStatus setThickness    (double);
	virtual	Ucad::ErrorStatus setConstantWidth(double);
	virtual	Ucad::ErrorStatus setNormal       (const UcGeVector3d&);

    ZSoft::Boolean    isOnlyLines     ()                        const;
    ZSoft::Boolean    hasPlinegen     ()                        const;
    double            elevation       ()                        const;
    double            thickness       ()                        const;
    Ucad::ErrorStatus getConstantWidth(double&)                 const;
    UcGeVector3d      normal          ()                        const;

    virtual Ucad::ErrorStatus addVertexAt     (unsigned int index,
                                       const UcGePoint2d& pt,
                                       double bulge = 0.,
                                       double startWidth = -1.,
                                       double endWidth = -1);

    virtual Ucad::ErrorStatus removeVertexAt  (unsigned int index);

    unsigned int      numVerts        ()                        const;

    Ucad::ErrorStatus getPointAt        (unsigned int index,
                                       UcGePoint2d& pt)         const;
    Ucad::ErrorStatus getBulgeAt      (unsigned int index,
                                       double&      bulge)      const;
    Ucad::ErrorStatus getWidthsAt     (unsigned int index,
                                       double&      startWidth,
                                       double&      endWidth)   const;

   virtual Ucad::ErrorStatus setPointAt(unsigned int index,
                                       const UcGePoint2d& pt);
   virtual Ucad::ErrorStatus setBulgeAt(unsigned int index,
                                       double       bulge);
   virtual Ucad::ErrorStatus setVertexIdentifierAt (unsigned int index, ZSoft::Int32 suggestedValue);
   virtual Ucad::ErrorStatus setWidthsAt     (unsigned int index,
                                       double       startWidth,
                                       double       endWidth);

    Ucad::ErrorStatus minimizeMemory  ();
    Ucad::ErrorStatus maximizeMemory  ();

    virtual void              reset           (ZSoft::Boolean reuse,
                                       unsigned int numVerts);

    ZSoft::Boolean     hasBulges       ()        const;
    ZSoft::Boolean     hasWidth        ()        const;
	
	DBCURVE_METHODS

    virtual Ucad::ErrorStatus getOsnapPoints(UcDb::OsnapMode osnapMode,
                                             ZSoft::GsMarker gsSelectionMark,
                                             const UcGePoint3d&  pickPoint,
                                             const UcGePoint3d&  lastPoint,
                                             const UcGeMatrix3d& viewXform,
                                             UcGePoint3dArray&      snapPoints,
                                             UcDbIntArray&   geomIds)
                                             const;

    virtual Ucad::ErrorStatus getGripPoints(UcGePoint3dArray&    gripPoints,
                                            UcDbIntArray& osnapMasks,
                                            UcDbIntArray& geomIds)
                                            const;

    virtual Ucad::ErrorStatus moveGripPointsAt(const UcDbIntArray& indices,  
                                               const UcGeVector3d& offset);

    virtual Ucad::ErrorStatus intersectWith(const UcDbEntity* ent,
                                            UcDb::Intersect intType,
                                            UcGePoint3dArray& points,
                                            ZSoft::GsMarker thisGsMarker  = 0,
                                            ZSoft::GsMarker otherGsMarker = 0)
                                            const;

    virtual Ucad::ErrorStatus intersectWith(const UcDbEntity* ent,
                                             UcDb::Intersect intType,
                                             const UcGePlane& projPlane,
                                             UcGePoint3dArray& points,
                                             ZSoft::GsMarker thisGsMarker  = 0,
                                             ZSoft::GsMarker otherGsMarker = 0)
                                             const;

    virtual Ucad::ErrorStatus getStretchPoints(UcGePoint3dArray&  stretchPoints)
                                               const;

    virtual Ucad::ErrorStatus moveStretchPointsAt(const UcDbIntArray& 
                                                 indices,
                                                 const UcGeVector3d& offset);

    virtual Ucad::ErrorStatus transformBy(const UcGeMatrix3d& xform);

    virtual Ucad::ErrorStatus getTransformedCopy(const UcGeMatrix3d& xform,
                                                 UcDbEntity*& ent) const;

    virtual void              getEcs(UcGeMatrix3d& retVal) const;

    virtual Ucad::ErrorStatus getGeomExtents(UcDbExtents& extents) const;

    virtual UcDbEntity*       subentPtr(const UcDbFullSubentPath& id) const;
    virtual Ucad::ErrorStatus getSubentPathsAtGsMarker(
                                 UcDb::SubentType     type, 
                                 ZSoft::GsMarker      gsMark,
                                 const UcGePoint3d&   pickPoint,
                                 const UcGeMatrix3d&  viewXform,
                                 int&                 numIds, 
                                 UcDbFullSubentPath*& subentIds,
                                 int                  numInserts,
                                 UcDbObjectId*        entAndInsertStack)
                                                                     const;

    virtual Ucad::ErrorStatus explode(UcDbVoidPtrArray& entitySet) const;

    virtual ZSoft::Boolean    worldDraw   (UcGiWorldDraw* mode);
    virtual void              viewportDraw(UcGiViewportDraw* mode);

    virtual Ucad::ErrorStatus applyPartialUndo(UcDbDwgFiler* filer,
                                               UcRxClass*    classobj);

    virtual bool              castShadows() const;
    virtual bool              receiveShadows() const;
    virtual Ucad::ErrorStatus dwgInFields(UcDbDwgFiler* filer);
    virtual Ucad::ErrorStatus dwgOutFields(UcDbDwgFiler* filer) const;
    virtual Ucad::ErrorStatus dxfInFields(UcDbDxfFiler* filer);
    virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* filer) const;

    virtual void              saveAs(UcGiWorldDraw* mode,
                                     UcDb::SaveType st);

    virtual Ucad::ErrorStatus getClassID(CLSID* pClsid) const;
    virtual void gripStatus(const UcDb::GripStat status);
    virtual Ucad::ErrorStatus   getGripPoints(UcDbGripDataPtrArray& grips,
        const double curViewUnitSize, const int gripSize,
        const UcGeVector3d& curViewDir, const int bitflags) const;
};

inline ZSoft::Boolean UcDbPolyline::isPlanar() const
{
    return ZSoft::kTrue;
}

inline Ucad::ErrorStatus UcDbPolyline::getStartParam(double& startParam) const
{
    startParam = 0.;
    return Ucad::eOk;
}

inline Ucad::ErrorStatus UcDbPolyline::getSpline(UcDbSpline*& spline) const
{
    return Ucad::eNotApplicable;
}

#pragma pack(pop)

#endif 
